home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.06 Jun 96 / 12.06 Tips < prev    next >
Encoding:
Text File  |  1996-05-10  |  7.1 KB  |  125 lines  |  [TEXT/R*ch]

  1. OpenDoc Frames and Facets
  2.   A major difficulty confronting every first time OpenDoc programmer is the
  3. difference between Frames and Facets.  Both seem to refer to the “portion of a
  4. window” concept expressed in PowerPlant as a “pane” and in other frameworks as a
  5. “view”.  In common frameworks, the pane hierarchy is both an embedding hierarchy
  6. and a visual hierarchy.  In OpenDoc, the embedding hierarchy (frame) is
  7. separated from the visual hierarchy (facet) to allow for more flexibility in
  8. imaging.
  9. In order to understand the separate roles for frame and facets, I have found it
  10. useful to create my own subtitles:
  11.  
  12. Frame – a contract for embedding
  13. Facet – a region of a GrafPort
  14.  
  15. Think of ODFrame, first and foremost, as a relationship between two parts; a
  16. frame is a contract between a container and its embedded content.  An embedded
  17. part is connected to its containing document only through its frames – if all
  18. the frames are closed, the part is no longer in the document.  The embedding
  19. hierarchy alternates between parts and frames: parts have embedded frames, which
  20. have parts, which have embedded frames, and so on.
  21. The ODFrame contract covers three primary areas: the shape of the embedded
  22. content, the view type (icon, thumbnail, or normal imaging), and the
  23. presentation format (particular to the kind of content, e.g. a chart, table, or
  24. graph).  The container and embedded content mutually agree on these areas during
  25. a process called “frame negotiation”.
  26. Either party can initiate frame negotiation.  For example, a browser might want
  27. to show both an icon and a normal image for a particular embedded part.  This
  28. container would create two embedding contracts, each with different shapes, view
  29. types, and presentations.  On the other hand, a game controller might want to
  30. negotiate an irregular pod-shaped frame for its alien-like control panels.  It
  31. would have to ask its containing part to approve this shape.
  32. Frames, however, are an abstract contract.  They are not portions of a window. 
  33. In particular, frames have no GrafPort, no offset location, and no front-to-back
  34. ordering.  To fulfill the abstraction, the container must make one or more
  35. facets for each frame that it wants to display.  By making a facet, the
  36. container makes the frame visible and allows the user to interact with it.
  37. Think of a facet as a region of a GrafPort.  A facet has a coordinate
  38. transformation to locate itself in the GrafPort, and a clip region to make sure
  39. it does not exceed its bounds.  A facet has a z-ordering, and can be highlighted
  40. or selected.  Facets (and not frames) form the visual hierarchy.  Importantly,
  41. facets cannot be negotiated.  The container has sole control over assigning
  42. facets to its embedded frames, though it must respect the negotiated frame shape
  43. when it does so.
  44. In most cases, the container creates only one facet per frame.  Multiple facets
  45. occur in situations where a container has a split-screen view, and the same
  46. frame is imaged in multiple locations, with different clip regions.  Another
  47. common use of facets is in page layout, where a frame might be split between the
  48. bottom of one page and the top of the succeeding page.  To create the gap
  49. between pages, the container assigns upper and lower facets to the frame.  But
  50. note that if a frame has multiple facets, they must all be in the same GrafPort.
  51.  If you want to image the same content in two different windows, you must create
  52. a second frame (contract) for the second window.
  53. If you think about it, the distinction between frames and facets makes logical
  54. sense.  Consider a database container that stores thousands of embedded parts.
  55. After a search, the database displays 3 or 4 of those embedded parts.  In this
  56. scenario, only the search results need facets (regions of a GrafPort) for
  57. display.  But the database needs frames (the contract governing embedding) for
  58. all of the thousands of parts.  It would likely want to remember the shape, view
  59. type, and presentation of each of these parts, so that when it needs to display
  60. them, it can show them just as they appeared the last time.  Frames represent
  61. the persistent contract between the database and its embedded items. Facets
  62. represent the visual regions of the currently displayed parts.
  63. For programmers with experience in other frameworks, the most important thing to
  64. remember is that a frame is not a portion of a window.  It is simply a
  65. negotiated contract governing the shape, view, and presentation for an embedded
  66. content.  This shape, view, and presentation becomes visible only when the
  67. container fulfills this contract by creating a facet for the part, thus
  68. specifying its GrafPort, origin, and clip shape.
  69.  
  70. Jeremy Roschelle
  71.  
  72. Yanking Ingenuity
  73. These days, installing RAM in some of the new Power Macintosh computers is not
  74. as easy as it was with the Macintosh II series.  So, here’s a tip for you Power
  75. Macintosh 8500 owners...
  76. If you need to get access to your motherboard to install RAM, VRAM, or more
  77. Cache RAM, you’re going to have to first remove the deep-seated processor card
  78. before the motherboard can be removed from the chassis.  This card is really
  79. difficult to remove because it is in there tight, and there just isn’t a lot of
  80. finger space to allow you to get a good grip on the card.  After a couple
  81. roughed-up knuckles and sore finger tips, I found the following sane approach to
  82. solving this headache:
  83. Take two small nylon cable ties (any color will do) and loosely loop them
  84. through the sturdy holes in the upper corners of the processor card.  Then, you
  85. can easily insert your fingers through the two cable tie loops and apply enough
  86. equal pressure to carefully remove the processor card.
  87. The good news is you can leave those cable ties in there in case you need future
  88. access to the motherboard (unless of course you have some other need for the
  89. holes).
  90. Disclaimer: this tip has been thoroughly tested on several Power Macintosh 8500
  91. computers and is bug-free.  It is possible that some of the other models could
  92. also benefit from this tip.
  93.  
  94. Mark D. Gerl
  95.  
  96. [On a related note – the processor daughter card in PowerMac 9500 has a tendency
  97. to wander out of its socket if you move the machine around.  This is fatal to
  98. the processor card.  The repair person who fixed mine suggests opening the
  99. machine and re-seating the card if you move it to a different office, etc. – sgs
  100. ]
  101.  
  102.  
  103. Immediate Drag Manager Feedback
  104. The Drag Manager allows a feeback region to be dragged by the mouse. This region
  105. is created and passed into the TrackDrag trap:
  106.  
  107.  TrackDrag(
  108.             DragReference         theDragRef,
  109.             const EventRecord*    theEvent,
  110.             RgnHandle             theRegion);
  111.  
  112. The Drag Manager doesn’t actually draw this region until the mouse has actually
  113. moved.  Sometimes it is helpful if this region is drawn immediately.  What to
  114. do?
  115. Just futz with the where field of theEvent by a few pixels.
  116.  
  117.         theEvent->where.h += 3;   // the 3 comes from DnD HIG, p. 7
  118.         theEvent->where.v += 3;
  119.         err = TrackDrag(theDragRef, theEvent, theRegion);
  120. ...and a comment on the XOR Anti-Tip
  121. One of the problems with the XOR swap (MacTech Magazine 11.10 [October 1995] 96)
  122. is that it doesn’t work if the source and destination are the same variables, as
  123. could happen with complicated, deeply nested macros.
  124. Chris Sears
  125.